﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Model_Add : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UserPower.CheckAction((int)FreeHouse.Power.Actions.TModel.Add);
    }
    protected void save_Click(object sender, EventArgs e)
    {
        error.Items.Clear();
        FreeHouse.Model.TModel model = new FreeHouse.Model.TModel();
        model.ModelName = ModelName.Text.Trim();
        model.Description = Server.HtmlEncode(Description.Value);

        if (model.ModelName == "")
            error.Items.Add(new ListItem("填写:ModelName"));
        //if (model.Description == "")
        //    error.Items.Add(new ListItem("填写:Description"));
        if (error.Items.Count == 0)
        {
            //判断ActionClassName是否存在
            FreeHouse.BLL.TModel bll = new FreeHouse.BLL.TModel();
            if (bll.Exists(model.ModelName))
            {
                error.Items.Add(new ListItem("TModel:" + model.ModelName + "已存在."));
            }
            else
            {
                if (bll.Add(model) > 0)
                    error.Items.Add(new ListItem("添加成功"));
            }

        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}
